Skip to content

net: support TCP_KEEPINTVL and TCP_KEEPCNT in setKeepAlive#63825

Merged
nodejs-github-bot merged 2 commits into
nodejs:mainfrom
guybedford:tcp-keepalive
Jun 13, 2026
Merged

net: support TCP_KEEPINTVL and TCP_KEEPCNT in setKeepAlive#63825
nodejs-github-bot merged 2 commits into
nodejs:mainfrom
guybedford:tcp-keepalive

Conversation

@guybedford

Copy link
Copy Markdown
Contributor

This extends setKeepAlive() for net.Socket based on the newer UV uv_tcp_keepalive_ex extension with allows setting these optional arguments for the probe interval and probe count, effectively closing the gap on setsockopt(2) compatibility.

This does not extend this option to other constructors accepting keepalive options currently although that could also be added as well.

Both new values default to the previous libuv behaviour (1000 ms interval, 10 probes), so existing calls are unaffected.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. net Issues and PRs related to the net subsystem. labels Jun 9, 2026
@guybedford guybedford force-pushed the tcp-keepalive branch 5 times, most recently from 88d729f to da04b2d Compare June 9, 2026 23:35
Signed-off-by: Guy Bedford <guybedford@gmail.com>
Comment thread doc/api/net.md Outdated
@addaleax addaleax added the semver-minor PRs that contain new features and should be released in the next minor version. label Jun 11, 2026

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 13, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 13, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@lpinca lpinca added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue Add this label to land a pull request using GitHub Actions. labels Jun 13, 2026
@nodejs-github-bot nodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Jun 13, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator
Commit Queue failed
- Loading data for nodejs/node/pull/63825
✔  Done loading data for nodejs/node/pull/63825
----------------------------------- PR info ------------------------------------
Title      net: support TCP_KEEPINTVL and TCP_KEEPCNT in setKeepAlive (#63825)
   ⚠  Could not retrieve the email or name of the PR author's from user's GitHub profile!
Branch     guybedford:tcp-keepalive -> nodejs:main
Labels     c++, net, semver-minor, author ready, needs-ci
Commits    2
 - net: support TCP_KEEPINTVL and TCP_KEEPCNT in setKeepAlive
 - add options bag variant
Committers 1
 - Guy Bedford <gbedford@cloudflare.com>
PR-URL: https://github.com/nodejs/node/pull/63825
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/63825
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
--------------------------------------------------------------------------------
   ℹ  This PR was created on Tue, 09 Jun 2026 23:04:58 GMT
   ✔  Approvals: 3
   ✔  - Anna Henningsen (@addaleax): https://github.com/nodejs/node/pull/63825#pullrequestreview-4480901640
   ✔  - Matteo Collina (@mcollina) (TSC): https://github.com/nodejs/node/pull/63825#pullrequestreview-4491068882
   ✔  - Luigi Pinca (@lpinca): https://github.com/nodejs/node/pull/63825#pullrequestreview-4491927594
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2026-06-13T08:03:07Z: https://ci.nodejs.org/job/node-test-pull-request/74085/
- Querying data for job/node-test-pull-request/74085/
✔  Build data downloaded
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  No git cherry-pick in progress
   ✔  No git am in progress
   ✔  No git rebase in progress
--------------------------------------------------------------------------------
- Bringing origin/main up to date...
From https://github.com/nodejs/node
 * branch                  main       -> FETCH_HEAD
✔  origin/main is now up-to-date
- Downloading patch for 63825
From https://github.com/nodejs/node
 * branch                  refs/pull/63825/merge -> FETCH_HEAD
✔  Fetched commits as 96cff6096ad7..2f3323944e40
--------------------------------------------------------------------------------
[main 27e6c29fed] net: support TCP_KEEPINTVL and TCP_KEEPCNT in setKeepAlive
 Author: Guy Bedford <gbedford@cloudflare.com>
 Date: Tue Jun 9 15:33:52 2026 -0700
 5 files changed, 109 insertions(+), 9 deletions(-)
 create mode 100644 test/parallel/test-net-keepalive-interval-count.js
[main 24f128b6cb] add options bag variant
 Author: Guy Bedford <gbedford@cloudflare.com>
 Date: Fri Jun 12 14:58:47 2026 -0700
 4 files changed, 116 insertions(+), 24 deletions(-)
   ✔  Patches applied
There are 2 commits in the PR. Attempting autorebase.
(node:463) [DEP0190] DeprecationWarning: Passing args to a child process with shell option true can lead to security vulnerabilities, as the arguments are not escaped, only concatenated.
(Use `node --trace-deprecation ...` to show where the warning was created)
Rebasing (2/4)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
net: support TCP_KEEPINTVL and TCP_KEEPCNT in setKeepAlive

Signed-off-by: Guy Bedford <guybedford@gmail.com>
PR-URL: #63825
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>

[detached HEAD 6136565c01] net: support TCP_KEEPINTVL and TCP_KEEPCNT in setKeepAlive
Author: Guy Bedford <gbedford@cloudflare.com>
Date: Tue Jun 9 15:33:52 2026 -0700
5 files changed, 109 insertions(+), 9 deletions(-)
create mode 100644 test/parallel/test-net-keepalive-interval-count.js
Rebasing (3/4)
Rebasing (4/4)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
add options bag variant

PR-URL: #63825
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>

[detached HEAD 05944613bf] add options bag variant
Author: Guy Bedford <gbedford@cloudflare.com>
Date: Fri Jun 12 14:58:47 2026 -0700
4 files changed, 116 insertions(+), 24 deletions(-)
Successfully rebased and updated refs/heads/main.

ℹ Add commit-queue-squash label to land the PR as one commit, or commit-queue-rebase to land as separate commits.

https://github.com/nodejs/node/actions/runs/27479323544

@addaleax addaleax added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. and removed commit-queue-failed An error occurred while landing this pull request using GitHub Actions. labels Jun 13, 2026
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jun 13, 2026
@nodejs-github-bot nodejs-github-bot merged commit 1efdce3 into nodejs:main Jun 13, 2026
86 of 87 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 1efdce3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. needs-ci PRs that need a full CI run. net Issues and PRs related to the net subsystem. semver-minor PRs that contain new features and should be released in the next minor version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants